﻿//-----------------------------------------------------------------------
// <copyright file="NoteFactory.cs" company="Mulala">
//     Copyright Mulala. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Mulala.Cavan.Domain.MainBoundedContext.InformationModule
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Mulala.Cavan.Domain.MainBoundedContext.SecurityModule;

    public static class NoteFactory
    {
        public static Note CreateNote(
                                string title,
                                string content,
                                InformationIdentifier.NoteType type,
                                UserAccount senderUserAccount,
                                bool isDeleted,
                                IList<NoteReceiver> noteReceivers,
                                string editUser)
        {
            Note note = new Note();
            int receiverCount = 0;
            if (null != noteReceivers && noteReceivers.Count > 0)
            {
                receiverCount = noteReceivers.Count;
                foreach (NoteReceiver nr in noteReceivers)
                {
                    nr.Note = note;
                }
            }
            note.Content = content;
            note.EditTime = DateTime.Now;
            note.EditUser = editUser;
            note.IsDeleted = isDeleted;
            note.NoteReceivers = noteReceivers;
            note.ReceiverCount = receiverCount;
            note.SenderUserAccount = senderUserAccount;
            note.Title = title;
            note.Type = type;
            note.CreateTime = DateTime.Now;

            return note;
        }

    }
}
